<?php
/**
 * @author GhostWei
 * @date 2012-7-16
 */
class controller_www_category extends picture_front_controller {
	
	public function init() {
		parent::init();
	}
	
	public function action_index() {
		$name = trim($this->_param('name'));
		$this->view->category = $category = $this->getCache()->getCategory(array('id' => $name, 'name' => $name));
		if(!$category) {
			throw new picture_front_exception("该专辑不存在");
		}
		$id = $category['id'];
		$adapter = new system_paginator_adapter_concept(new picture_special_concept($this->_lang()));
		$adapter->setCurrentPageNumber(intval($this->_param('page', 1)));
		$adapter->setLimit(30);
		$adapter->where("special.id IN(SELECT `special_id` FROM `picture_special_category` WHERE `lang` = '{$this->_lang()}' AND `category_id` = '$id')");
		$this->view->specialList = new system_paginator($adapter);		
		$this->_crumbs()->addPage(system_nav_page::create($category['title'])->setRoute('category/index')->setParams(array('name' => $name)));
		$this->render();
	}
	
}
